using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Toenda.Rails.System;
using Toenda.Rails.DataContainer;

public partial class Controls_Main_ctrl_tags : System.Web.UI.UserControl {
	private AccountProvider ap = new AccountProvider();
	private ImageProvider ip = new ImageProvider();

	/// <summary>
	/// Page_Load
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	protected void Page_Load(object sender, EventArgs e) {
		ArrayList arr = ip.GetTagPopularityList();

		TagItem tmp = new TagItem();
		//double last = 0.0;
		//double current = 0.0;
		double max = Convert.ToDouble(ip.GetMostlyUsedTagAmount());

		double val = (max / 6);
		double itemval = 0.0;
		int size = 0;

		string css = "popularTag";
		
		foreach(TagItem item in arr) {
			itemval = Convert.ToDouble(item.Amount);

			if(itemval <= (val * 1)) {
				size = 14;
				css = "unPopularTag";
			}
			else if(itemval <= (val * 2)) {
				size = 16;
				css = "popularTag";
			}
			else if(itemval <= (val * 3)) {
				size = 18;
				css = "popularTag";
			}
			else if(itemval <= (val * 4)) {
				size = 20;
				css = "popularTag";
			}
			else if(itemval <= (val * 5)) {
				size = 22;
				css = "popularTag";
			}
			else if(itemval <= (val * 6)) {
				size = 24;
				css = "popularTag";
			}

			if(item.Tag != "") {
				HyperLink link = new HyperLink();
				link.CssClass = css;
				link.Style.Add(HtmlTextWriterStyle.FontSize, size.ToString() + "px");
				link.Text = item.Tag;
				//link.NavigateUrl = "~/search.aspx?tag=" + item.Tag + "&target=a";
				link.NavigateUrl = "~/tag/" + item.Tag + "/default.aspx";

				plcLinks.Controls.Add(link);
				plcLinks.Controls.Add(new LiteralControl(" "));
			}
		}
	}
}
